<!DOCTYPE html>
<html>
<head>
    <title>微信公众号支付</title>
    <meta charset="utf-8" />
    <meta name="viewport" content="initial-scale=1.0, width=device-width, user-scalable=no" />
</head>
<body class="bc-bg" >
<div class="wenx_xx">
    <div class="mz">微信公众号交易付款</div>
    <div class="wxzf_price">￥{pay_cash}</div>
</div>
<a href="javascript:void(0);" class="ljzf_but all_w" onClick="callpay()">立即支付</a>
</body>

<script type="text/javascript">
    var trade_obj = {jsApiParameters};
    (function () {
        var titHeight = $('#header').height();
        $('.mrcontent').css({'margin-top': titHeight});
    })();
    //调用微信JS api 支付
    function jsApiCall() {
        WeixinJSBridge.invoke(
            'getBrandWCPayRequest',
            trade_obj,
            function (res) {
                if (res.err_msg == 'get_brand_wcpay_request:ok') {

                    alert("支付成功做些操作");
                }else{

                    alert("支付失败做些操作");
                }
            }
        )
        ;
    }

    function callpay() {
        if (typeof WeixinJSBridge == "undefined") {
            if (document.addEventListener) {
                document.addEventListener('WeixinJSBridgeReady', jsApiCall, false);
            } else if (document.attachEvent) {
                document.attachEvent('WeixinJSBridgeReady', jsApiCall);
                document.attachEvent('onWeixinJSBridgeReady', jsApiCall);
            }
        } else {
            jsApiCall();
        }
    }
</script>